import type { Directive } from 'vue'

export const debounce: Directive = {
  mounted(el: HTMLButtonElement, binding) {
    let timer: any = null
    el.addEventListener('input', () => {
      if (timer) {
        clearTimeout(timer)
      }
      timer = setTimeout(() => {
        binding.value(el.value)
      }, 500)
    })
  }
}
